import {UserPageSettingType} from "../type/UserPageSetting";


class System {
    private static readonly SETTING_KEY = "userPageSetting" ;
    private static readonly instance = new System() ;

    private constructor() {
    }

    public static getInstance(): System {
        return this.instance ;
    }

    /**
     * 从本机获取用户页面配置
     */
    public getUserConfig(): UserPageSettingType {
        return JSON.parse(localStorage.getItem(System.SETTING_KEY) || "{}") ;
    }

    /**
     * 写入用户页面配置到本地
     * @param config
     */
    public writeConfigToLocal(config: UserPageSettingType):void {
        localStorage.setItem(System.SETTING_KEY,JSON.stringify(config)) ;
    }
}

export default System;